﻿<%@ Page Language="C#" validateRequest="false" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="msg_send_edit.aspx.cs" Inherits="Ccit.SysPlat.Remind.msg_send_edit" %>

<%@ Register TagPrefix="ccit" TagName="attach" Src="../UserControls/AttachUpLoad.ascx" %>

<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>在线消息-撰写消息</title>
    <script language="javascript" type="text/javascript" src="../script/jwindow.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jsonlib.js"></script>
    <script language="javascript" src="../script/jquery.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jcontrol.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="../script/jbase64.js"></script>
    
    <script language="javascript" type="text/javascript">
            var tabPageArray = [];
            var tabTitleArray = [];
            
            function doChangeTab(tabSign){                
                var curSelTabSign = document.getElementById("_hidSelTab").value;                
                if(tabPageArray.length == 0) {
                    initTabPageArray();
                    initTabTitleArray();
                }
                                
                // set new select tab style
                setTabSelected(tabSign);
                
                // restore origin tab style
                setTabUnSel(curSelTabSign);
                
                document.getElementById("_hidSelTab").value = tabSign;                 
                self.window.frames[0].document.location.href = findInfo(tabSign,tabPageArray);
            }
            
            function initTabPageArray() {
                var liItem;               
                var organPageParam="pageFlag=1";    //组织机构
                var organEncodeParam=base64encode(organPageParam);
                liItem = new ListItem("organ","./msg_send_usersel.aspx?"+organEncodeParam);
                tabPageArray.push(liItem);       
                         
                var onlinePageParam="pageFlag=2";    //在线状态
                var onlineEncodeParam=base64encode(onlinePageParam);
                liItem = new ListItem("online","./msg_send_usersel.aspx?"+onlineEncodeParam);
                tabPageArray.push(liItem);         
                       
                var recentPageParam="pageFlag=3";    //近期联系人
                var recentEncodeParam=base64encode(recentPageParam);
                liItem = new ListItem("recentPerson","./msg_send_usersel.aspx?"+recentEncodeParam);
                tabPageArray.push(liItem);
            }
            
            function initTabTitleArray() {
                var liItem;
                liItem = new ListItem("organ","组织机构");
                tabTitleArray.push(liItem);
                
                liItem = new ListItem("online","在线状态");
                tabTitleArray.push(liItem);
                
                liItem = new ListItem("recentPerson","近期联系人");
                tabTitleArray.push(liItem);
            }
            
            function findInfo(tabSign,tabInfoArray) {
                var itemCount = tabInfoArray.length;
                var liItem;
                var retInfo = "";
                for(var i = 0; i < itemCount; i ++) {
                    liItem = tabInfoArray[i];
                    if(liItem.Text == tabSign) {
                        retInfo = liItem.Value;
                        break;
                    }
                }
                return retInfo;
            }
            
            /* 页签选中 */
            function setTabSelected(tabSign) {
                if(tabSign == "organ")
                {
                    var ddlCtrl = document.getElementById("ddlType");
                    ddlCtrl.disabled = "";
                    ddlCtrl.selectedIndex = "0";
                }
                else
                {
                    var ddlCtrl = document.getElementById("ddlType");
                    ddlCtrl.disabled = "disabled";
                    ddlCtrl.selectedIndex = "1";
                }
                var leftImgId = "ast_left_" + tabSign;
                var rightImgId = "ast_right_" + tabSign;                
                var ctrlTab = document.getElementById(tabSign);
                var aId = "a" + tabSign;
                var aCtrl = document.getElementById(aId);
                
                document.getElementById(leftImgId).src = "../images/pagetab_h_left.gif";
                ctrlTab.background = "../images/pagetab_bg_high.gif";
                ctrlTab.className = "PageTabRangeSelect";                
                aCtrl.innerHTML = "<B>" + findInfo(tabSign,tabTitleArray) + "</B>";
                aCtrl.className = "linktext";
                document.getElementById(rightImgId).src = "../images/pagetab_h_right.gif";
            }
            
            /* 页签未选中 */
            function setTabUnSel(tabSign){
                var leftImgId = "ast_left_" + tabSign;
                var rightImgId = "ast_right_" + tabSign;
                var ctrlTab = document.getElementById(tabSign);
                var aId = "a" + tabSign;
                var aCtrl = document.getElementById(aId);
                
                document.getElementById(leftImgId).src = "../images/pagetab_l_left.gif";
                ctrlTab.background = "../images/pagetab_bg_low.gif";
                ctrlTab.className = "PageTabRange";
                aCtrl.innerHTML = findInfo(tabSign,tabTitleArray);
                aCtrl.className = "linktabtext";
                document.getElementById(rightImgId).src = "../images/pagetab_l_right.gif";
            }

            /* UpLoad File */
            function doUploadFile() {
                OpenUpLoadPage();
            }
            
            /* 查询 */
            function doSearch()
            {
                var selTab = document.getElementById("_hidSelTab").value;
                var ddlCtrl = new DropDownList("ddlType");
                var ddlSel = ddlCtrl.selectedValue;
                var filter = document.getElementById("txtFilter").value;
                if(filter == "")
                {
                    alert("请输入要筛选的字符串");
                    return;
                }
                var selNodeId = window.frames[0].document.getElementById("_hidSelNodeId").value;
                var haveChild = window.frames[0].document.getElementById("_hidHaveChild").value;
                var nodeType = window.frames[0].document.getElementById("_hidNodeType").value;
                PageMethods.FindFilter(ddlSel,filter,selTab,selNodeId,haveChild,nodeType,ClientCallBack);
            }
            
            function ClientCallBack(vResult) {
                if (vResult == null || vResult == "") return;
                
                eval("var resultObj=" + vResult);
                var operType = resultObj.operType;
                switch (operType)
                {
                    case "filter":
                        var lstResult = resultObj.lstResult;
                        var flag = lstResult[0];
                        if (flag < 0) {
                            alert(lstResult[2]);
                        }
                        else if (flag > 0) {
                            window.frames[0].document.getElementById("_hidFindId").value = lstResult[1];
                            window.frames[0].document.getElementById("_hidNodeType").value = lstResult[3];
                            window.frames[0].document.all.btnTrigger.click();
                        }
                        else {
                            alert("没有您要找的结果");
                        }
                        break;
                }
            }
            
            /* 发送 */
            function doSend() {
                var MsgContent = jQuery.trim(document.getElementById("txtaraContent").value);
                if(MsgContent == "")
                {
                    alert("消息内容不能为空");
                    return false;
                }
                var userIds = window.frames[0].GetcheckUserIds();
                if(userIds == "")
                {
                    alert("请选择收件人");
                    return false;
                }
                
                var userArr = userIds.split(",");
                var oStrResult="";
                for(var i=0;i<userArr.length;i++)
                {
                    var oUser=userArr[i];
                    var ostr=oUser.split("_");
                    if(ostr[2]!="dept"||ostr[1]!="1")
                        oStrResult+=(oStrResult=="") ? oUser : ","+oUser;
                }

                document.getElementById("_hidCheckedUserIds").value = oStrResult;                
                document.getElementById("_hidMsgContent").value = MsgContent;            
                __doPostBack("lnkSend","");
            }
            
            /* 取消 */
            function doCancle()
            {
               var vPageSource = document.getElementById("_hidPageSource").value;
               if (vPageSource == "1") //接收消息列表页面
               {
                   window.opener.__doPostBack("lnkSearch", "");
                   window.close();
               }
               else if (vPageSource == "2") //发送消息列表页面
               {
                   window.opener.__doPostBack("lnkSearch", "");
                   window.close();
               }
               else if (vPageSource == "3")  //查看消息页面
               {
                   window.opener.__doPostBack("lnkSearch", "");
                   window.close();
               }
               else if (vPageSource == "5")  //近期联系人
               {
                   window.opener.__doPostBack("lnkSearch", "");
                   window.close();
               }
               else if (vPageSource == "6")  //近期消息浏览
               {
                   window.close();
               }
               else {
                   document.location = "msg_send_edit.aspx";  //本身
               }
            }
    </script>
</head>
<body style="height:99%;width:99%">
    <ccit:ActionForm id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    <input type="hidden" id="_hidSelTab" runat="server" />
    
    <input type="hidden" id="_hidMsg" runat="server" />
    <input type="hidden" id="_hidCurCount" runat="server" />
    <input type="hidden" id="_hidPageSource" runat="server" />
    <input type="hidden" id="_hidFlag" runat="server" />
    
    <input type="hidden" id="_hidSenderId" runat="server" />
    
    <input type="hidden" id="_hidCheckedUserIds" runat="server" />
    <input type="hidden" id="_hidMsgContent" runat="server" />
    
    <asp:LinkButton ID="lnkSend" runat="server" Visible="false" onclick="lnkSend_Click"></asp:LinkButton>
    
    <table class="tbToolbar" id="tabHead"  cellpadding="0" cellspacing="0" align="center" width="98%" height="15%">
      <tr>
        <td align="left">
          <div class="tbSeparator"></div>
        </td>
        <td width="100%" class="titlebar">在线消息-撰写消息</td>
         <td align="right">
          <div class="tbSeparator"></div>
        </td>
      </tr>
    </table>
    
   <table cellpadding="0" cellspacing="0" width="98%" border="0" class="tableborder" style="width:98%;" align="center">
      <tr>
         <td style="width:63%;  height:98%;" valign="top" align="center">
             <table class="tableborder" cellpadding="0" cellspacing="0" width="98%" align="center" runat="server" id="tab1">
              <tr>
                <td width="10%" valign="top" class="pformleft">内容</td>
                <td class="pformright">
                  <textarea id="txtaraContent" rows="3" class="inputarea" runat="server" cols="30" style="width:100%; height:370px" ></textarea> 
                </td>
              </tr>
              <tr>
                <td width="10%"  class="pformleft">附件</td>
                <td class="pformright" >
                    <a id="A1" href="javascript:doUploadFile()" runat="server" class="linktext">上传附件</a>
                </td>
              </tr>
              <tr>
                <td class="pformright" colspan="2" style="width:100%" align="left">
                    <ccit:attach id="ucAttach" ShowStyle="1" runat="server"></ccit:attach>
                </td>
              </tr>
             </table>
         </td>
         <td style="width:35%; height:98%; padding-top:3px" valign="top" align="center">
                <table cellpadding="0" cellspacing="0" width="98%" height="99%" align="center" runat="server" id="Table1">
                  <tr>
                    <td align="left">
                       <nobr>
                        <asp:DropDownList ID="ddlType" runat="server" CssClass="select">
                           <asp:ListItem Value="1">部门</asp:ListItem>
                           <asp:ListItem Value="2">人员</asp:ListItem>
                        </asp:DropDownList> 
                        <input type="text" class="input" style="width:63%" id="txtFilter" />
                        <a href="javascript:doSearch()"  class="linktext">
                            <img src="../images/toolbar/search.gif" />
                        </a>
                       </nobr>
                    </td>
                  </tr>
                  <tr>
                    <td align="left">
                        <table cellpadding="0" cellspacing="0" align="left">
                          <tr>
                            <td width='1'><img src='../images/pagetab_h_left.gif'  id='ast_left_organ'></td>
                            <td width='80' valign='middle' align='center' background='../images/pagetab_bg_high.gif' id="organ" class='PageTabRangeSelect'>
                                <nobr>&nbsp;<a id="aorgan" class="linktext" href="javascript:doChangeTab('organ')"><B>组织机构</B>&nbsp;&nbsp;</a></nobr>
                            </td>
                            <td width='1'><img src='../images/pagetab_h_right.gif'  id='ast_right_organ'></td>
                            <td width='1'><img src='../images/pagetab_l_left.gif'  id='ast_left_online'></td>
                            <td width='80' valign='middle' align='center' background='../images/pagetab_bg_low.gif' id='online' class='PageTabRange'>
                                <nobr>&nbsp;<a id="aonline" href="javascript:doChangeTab('online');" class='linktabtext'>在线状态</a>&nbsp;&nbsp;</nobr>
                            </td>
                            <td width='1'><img src='../images/pagetab_l_right.gif'  id='ast_right_online'></td>
                            <td width='1'><img src='../images/pagetab_l_left.gif'  id='ast_left_recentPerson'></td>
                            <td width='80' valign='middle' align='center' background='../images/pagetab_bg_low.gif' id='recentPerson' class='PageTabRange'>
                                <nobr>&nbsp;<a id="arecentPerson" href="javascript:doChangeTab('recentPerson');" class='linktabtext'>近期联系人</a>&nbsp;&nbsp;</nobr>
                            </td>
                            <td width='1'><img src='../images/pagetab_l_right.gif'  id='ast_right_recentPerson'></td>  
                            <td background='./images/pagetab_bg.gif'>&nbsp;</td>             
                        </tr>            
                       </table>
                    </td>
                  </tr>
                  <tr>		
                    <td>
                        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CECECE"	height="3">	
                            <tr>
                                <td width="100%">
                                    <div id="toolbar_text"></div>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr> 
                  <tr>
                    <td valign="top" style="border-right:#CDCECF 1px solid;border-left:#CDCECF 1px solid;border-bottom:#CDCECF 1px solid;border-top:#D9D9DA 0px solid;height:100%">                    
                        <iframe id="iFrmView" name="iFrmView" height="99%" width="100%" scrolling="auto" frameborder="0" >
                        </iframe>
                    </td>
                  </tr>
                </table>
          </td> 
      </tr>
      <tr class="pformstrip" width="98%">
            <td colspan="2" align="center">
               <input type="button" runat="server" id="btnSend"  class="button" value="发送" onclick="doSend()"/>
               &nbsp;&nbsp;&nbsp;
               <input type="button" runat="server" id="btnCancle"  class="button" value="取消" onclick="doCancle()"/>
            </td>
      </tr>
    </table>
    </ccit:ActionForm>
    
    <script type="text/javascript">
    <!--
        $(document).ready(function() {
            var pageSource = document.getElementById("_hidPageSource").value;
            if (pageSource == "0")
                document.getElementById("btnCancle").style.display = "none";

            var curSelTabSign = document.getElementById("_hidSelTab").value;

            if (tabPageArray.length == 0) {
                initTabPageArray();
                initTabTitleArray();
            }

            // set new select tab style
            setTabSelected(curSelTabSign);

            if (curSelTabSign != "organ")
                setTabUnSel("organ");

            var strURL = findInfo(curSelTabSign, tabPageArray)
            self.window.frames[0].document.location.href = strURL;
        });
        
    //-->
    </script>
</body>
</html>
